var HostUrl = "http://dev.goldtimes.com/index.php?d=backstage&c=user/";
var Bline = {
	login:"login",
	regist:"registe",
	logout:"logout"
}
function sub(){
	var uid = $("#uid").val();
	var passwd = $("#password").val();
	$("#uid").val($.trim(uid));
	var reg2=/^\w{8,15}$/;
	if(!isMobile(uid)){
		$("#errorMsg").text("用户名格式错误，请重新输入！");
		return false;
	}
	if(!reg2.test(passwd)){
		$("#errorMsg").text("密码格式错误，请重新输入！");
		return false;
	}
	$.ajax({
		type:"get",
		dataType:"json",
		url: HostUrl + Bline.login,
		data:{
			"phone":uid,
			"code":passwd
		},
		success:function(res){
			if (res.code == "0") {
				document.cookie="token="+res.msg+";path=/";
				document.cookie="name="+res.name+";path=/";
				window.location.href="index.php?d=backstage&c=Rendering/index";
			}else if(res.code == "404"){
				$("#errorMsg").text("请先注册后再登陆!");
			}else {
				$("#errorMsg").text("帐号密码错误!");
			}
		}
	})
}

	
function isMobile(str){
	if(typeof(str)=="object") str=str.value;
	var regu =/^1[3-8]\d{9}$/;
	var re = new RegExp(regu);
	if (re.test( str )) {
	  return true;
	}
	return false;
}


